<?php require_once('../../Connections/cotiza.php'); ?>
<?php require_once('../../include/defaults.php'); ?>
<?php require_once("../../include/language.php"); ?>
<?php require_once("../lib/functions.php"); ?>
<?php
noCache();
?>
<?php
//session_start();
mysql_select_db($database_cotiza, $cotiza);

$acc     = $_GET['acc'];
$cod_imp = $_GET['cod_impresora'];

if($acc == "save")
{
	$cod    = $_POST['cod'];
	$desc   = $_POST['desc'];
	$caras  = asigna_valor($_POST['caras']);
	$anma   = asigna_valor($_POST['anma']);
	$amap   = asigna_valor($_POST['amap']);
	$deci   = asigna_valor($_POST['deci']);
	$colo   = asigna_valor($_POST['colo']);
	
	$query_insert = "INSERT INTO imp_mstr(imp_id, imp_desc, imp_caras, imp_anmaxim, imp_anmaxpt, imp_descil, imp_colores) VALUES ('$cod', '$desc', $caras, $anma, $amap, $deci, $colo)
		             ON DUPLICATE KEY UPDATE imp_desc = '$desc', imp_caras = $caras, imp_anmaxim = $anma, imp_anmaxpt = $amap, imp_descil = $deci, imp_colores = $colo";
	mysql_query($query_insert, $cotiza) or die(mysql_error());
	//echo $query_insert;
	//header("Location: mntoimpresoras.php");
}

if($acc == "edit" and $cod_imp != "")
{	
	$cod_impresora = $cod_imp;
	$query     = "SELECT * FROM imp_mstr where imp_id = '$cod_impresora'";
	$registros = mysql_query($query, $cotiza) or die(mysql_error());
	$row       = mysql_fetch_assoc($registros);
	$totalRows = mysql_num_rows($registros);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>...::: MNTO Impresoras :::...</title>
<link href="../../main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../lib/funciones.js"></script>
</head>

<body>
<strong>Impresi&oacute;n</strong>
<form id="form1" name="form1" method="post" action="mntoimpresoras.php?acc=save">
<table border="0">
  <tr>
    <td width="140">Cod. Extrusora</td>
    <td width="4">:</td>
    <td width="100"><input name="cod" type="text" class="default <?php if($cod_impresora != "") echo "borde_trasparente"; ?>" id="cod" size="20" autocomplete="off" <?php if($cod_impresora != "") echo "readonly=\"readonly\" value=\"$cod_impresora\""; else echo " onkeypress=\"check_key(event,'mntoimpresoras.php?acc=edit&cod_impresora=' + this.value)\" value=\"$cod_imp\""; ?>/></td>
    <td width="97"><?php if($cod_impresora == "") { ?><a href="javascript:abrir('../browser/impresoras.php','cod',370,450)"><img src="../img/find.png" width="16" height="16" border="0" /></a><?php } ?></td>
  </tr>
  <tr>
    <td>Descripci&oacute;n</td>
    <td>:</td>
    <td colspan="2"><input name="desc" type="text" class="default" id="desc" size="40" <?php if($cod_impresora == "") echo "style=\"visibility:hidden\""; ?> value="<?php echo $row['imp_desc']; ?>" /></td>
    
  </tr>
</table>
<br />
<div id="detail-ext" style=" <?php if($cod_impresora == "") echo "visibility:hidden"; ?>">
  <table border="0">
    <tr>
    <td width="140">Impresion 1 o 2 caras</td>
    <td>:</td>
    <td><select name="caras" class="default" id="caras">
      <option value="1" <?php if($row['imp_caras'] == "1") echo "selected=\"selected\"";?>>1</option>
      <option value="2" <?php if($row['imp_caras'] == "2") echo "selected=\"selected\"";?>>2</option>
    </select></td>
    <td width="279">&nbsp;</td>
  </tr>
  <tr>
    <td>Ancho M&aacute;ximo impresi&oacute;n</td>
    <td>:</td>
    <td colspan="2"><input name="anma" type="text" class="default" id="anma" onkeypress="return valida_numeros(event)" size="3" value="<?php echo $row['imp_anmaxim']; ?>"/>
    mm</td>
  </tr>
  <tr>
    <td>Ancho M&aacute;ximo pasadas telas</td>
    <td>:</td>
    <td colspan="2"><input name="amap" type="text" class="default" id="amap" onkeypress="return valida_numeros(event)" size="3" value="<?php echo $row['imp_anmaxpt']; ?>"/>
      mm</td>
  </tr>
  <tr>
    <td>Desarrollo Cilindros (1-30)</td>
    <td>:</td>
    <td colspan="2"><input name="deci" type="text" class="default" id="deci" onkeypress="return valida_numeros_enteros(event)" size="3" value="<?php echo $row['imp_descil']; ?>"/></td>
  </tr>
  <tr>
    <td>N&uacute;mero m&aacute;ximo de colores</td>
    <td>:</td>
    <td colspan="2"><select name="colo" class="default" id="colo">
      <option value="1" <?php if($row['imp_colores'] == "1") echo "selected=\"selected\"";?>>1</option>
      <option value="2" <?php if($row['imp_colores'] == "2") echo "selected=\"selected\"";?>>2</option>
      <option value="3" <?php if($row['imp_colores'] == "3") echo "selected=\"selected\"";?>>3</option>
      <option value="4" <?php if($row['imp_colores'] == "4") echo "selected=\"selected\"";?>>4</option>
      <option value="5" <?php if($row['imp_colores'] == "5") echo "selected=\"selected\"";?>>5</option>
      <option value="6" <?php if($row['imp_colores'] == "6") echo "selected=\"selected\"";?>>6</option>
      <option value="7" <?php if($row['imp_colores'] == "7") echo "selected=\"selected\"";?>>7</option>
      <option value="8" <?php if($row['imp_colores'] == "8") echo "selected=\"selected\"";?>>8</option>
    </select></td>
  </tr>
  </table>
</div>
<script>
try{
	var foc = '<?php echo $cod_impresora;?>';
	
	if(foc != "")
		document.getElementById('desc').focus();
	else
		document.getElementById('cod').focus();
}
catch(e)
{
}
</script>
<br />
</form>
<br />
<table width="479" border="0">
  <tr>
    <td width="272" align="left" class="descripcion_alpie" ><?php if($acc == "edit" and $totalRows == 0)echo $text_newreg; if($acc == "edit" and $totalRows == 1)echo $text_editreg; ?></td>
      <td width="86" align="right"><?php if ($id_usuario == ""){?>
      <input name="button" type="button" onclick="ir('mntoimpresoras.php?acc=edit&cod_familia=' + document.getElementById('cod').value,'_self')" class="default" id="button" value="Editar" />
      <?php }?></td>
    <td width="46" align="right"><input name="button2" type="button" onclick="window.open('mntoimpresoras.php?cod_impresora=<?php echo $cod_impresora; ?>','_self');" class="default" id="button2" value="Volver" <?php if($cod_imp == "") echo "disabled=\"disabled\""; ?> /></td>
    <td width="56" align="right"><input name="Submit" type="button" class="default" value="Guardar" onclick="document.forms.form1.submit()" <?php if($cod_impresora == "") echo "disabled=\"disabled\""; ?> /></td>
    </tr>
</table>

</body>
</html>
<?php 
mysql_close($cotiza);
?>